
#include <Chance.h>
#include <assert.h>
#include <math.h>

#define FLT_EPSILON  exp(-32)

Chance::Chance(double chance):chance_m(chance)
{
	assert(chance >=0 && chance <= 1);
}

double Chance::getValue() const
{
	return (chance_m);
}

bool Chance::operator ==(const Chance& rhs) const
{
	return (fabs(chance_m - rhs.getValue()) < FLT_EPSILON);
}

Chance Chance::operator *(const Chance& rhs) const
{
	return Chance(chance_m * rhs.getValue());
}

Chance Chance::operator +(const Chance& rhs) const
{
	return Chance(chance_m + rhs.getValue());
}

Chance Chance::operator !() const
{
	return Chance(1 - chance_m);
}


